﻿@model WebUI.Models.QizItem
@using (Ajax.BeginForm(new AjaxOptions()
{
    LoadingElementId = "OnLoadingSpan",
    UpdateTargetId = "SuiFangFormView",
    InsertionMode = InsertionMode.Replace,
    HttpMethod = "Post",
    OnSuccess = "$('#dialogbox').dialog('close');",
    OnFailure = "OnSiteError"
}))
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>@Model.Catalog.Title\随访单</legend>
        @Html.HiddenFor(model => model.QizItemID)
        @Html.HiddenFor(model => model.CatalogID)
        <table width="100%">
            <tr>
                <td colspan="2" class="big-input">
                    <div class="editor-label">
                        @Html.LabelFor(model => model.Title)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.Title)
                        @Html.ValidationMessageFor(model => model.Title)
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="editor-label">
                        @Html.LabelFor(model => model.Unit)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.Unit)
                        @Html.ValidationMessageFor(model => model.Unit)
                    </div>
                    <div class="editor-label">
                        @Html.LabelFor(model => model.Format)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.Format)
                        @Html.ValidationMessageFor(model => model.Format)
                    </div>
                    @*<div class="editor-label">
                        @Html.LabelFor(model => model.SortIdx)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.SortIdx)
                        @Html.ValidationMessageFor(model => model.SortIdx)
                    </div>*@
                    @{Model.SortIdx = 0;}
                    @Html.HiddenFor(model => model.SortIdx)
                    <span style="display: none">
                        <div class="editor-label">
                            @Html.LabelFor(model => model.Department)
                        </div>
                        <div class="editor-field">
                            @Html.DropDownListFor(model => model.DepID, new SelectList(ViewBag.Departments, "DepartmentID", "DepName"))
                            @Html.ValidationMessageFor(model => model.DepID)
                        </div>
                    </span>
                    <div class="editor-label">
                        @Html.LabelFor(model => model.TypeRef)
                    </div>
                    <div class="editor-field">
                        @Html.DropDownListFor(model => model.Type, new SelectList(ViewBag.Types, "EnumValID", "OptionTitle", Model.Type), new { onchange = "ModelTypeFieldChanged(this.value)" })
                        @Html.ValidationMessageFor(model => model.Type)
                        <span id="enumid">
                            @Html.EditorFor(model => model.EnumID, "SelField", new { Selects = new SelectList(ViewBag.EnumDefines, "EnumID", "EnumName", Model.EnumID) })
                            <script type="text/javascript">
                                function ModelTypeFieldChanged(val) {
                                    $("#enumid select").attr("disabled", val != "204" && val != "205");
                                }

                                $(function () {
                                    ModelTypeFieldChanged("@(Model.Type)");
                                });
                            </script>
                        </span>
                    </div>
                    <div class="editor-label">
                        @Html.CheckBoxFor(model => model.SpecialItem) @Html.LabelFor(model => model.SpecialItem)
                        &nbsp;&nbsp;&nbsp;
                        @Html.CheckBoxFor(model => model.RequiredItem) @Html.LabelFor(model => model.RequiredItem)
                    </div>
                </td>
                <td>
                    <div class="editor-label">
                        @Html.LabelFor(model => model.Length)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.Length)
                        @Html.ValidationMessageFor(model => model.Length)
                    </div>
                    <div class="editor-label">
                        @Html.LabelFor(model => model.Precision)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.Precision)
                        @Html.ValidationMessageFor(model => model.Precision)
                    </div>
                    <div class="editor-label">
                        @Html.LabelFor(model => model.ThresholdLow)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.ThresholdLow)
                        @Html.ValidationMessageFor(model => model.ThresholdLow)
                    </div>
                    <div class="editor-label">
                        @Html.LabelFor(model => model.ThresholdHight)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.ThresholdHight)
                        @Html.ValidationMessageFor(model => model.ThresholdHight)
                    </div>
                </td>
            </tr>
        </table>
        <p>
            <input type="submit" value="确定" />
        </p>
    </fieldset>
}